package com.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.common.constant.SharesConstan;
import com.common.utils.DateUtil;
import com.common.utils.MeUtils;
import com.common.utils.Result;
import com.common.utils.StringUtil;
import com.entity.*;
import com.service.*;
import com.vo.SharesZdfCopyVo;
import com.vo.SharesZjlx;
import com.vo.SshyPrecentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@CrossOrigin(allowCredentials = "true", allowedHeaders = "*")
@RestController
@RequestMapping("/shares")
public class SharesController {

    @Autowired
    private HintSharesService hintSharesService;

    @Autowired
    private SharesNoticeService sharesNoticeService;

    @Autowired
    private SharesHyzxService sharesHyzxService;

    @Autowired
    private SharesReviewService sharesReviewService;

    @Autowired
    private SharesDetailService sharesDetailService;

    @Autowired
    private HintNumService hintNumService;

    /**
     * 持仓股
     */
    @RequestMapping("/ccShares")
    public Result ccShares(){
        List<HintShares> hList=new ArrayList<>();
        for (String vo : SharesConstan.GZ_SHARES.keySet()) {
            HintShares hintShares = SharesConstan.GZ_SHARES.get(vo);
            if(null!=hintShares){
                hList.add(hintShares);
            }
        }
        return  Result.success(hList);
    }

    /**
     * 添加持仓股
     */
    @RequestMapping("/addCcShares")
    public Result addCcShares(HttpServletRequest request){
        String code = request.getParameter("code");
        HintShares hintShares = SharesConstan.GZ_SHARES.get("sz" + code);
        if(null==hintShares){
            SharesConstan.GZ_SHARES.put("sz"+code,null);
        }
        return  Result.success("添加成功");
    }

    /**
     * 添加关注股
     */
    @RequestMapping("/addShares")
    public Result addShares(HttpServletRequest request) {
        String code = request.getParameter("code");
        String type= request.getParameter("type");
        if(StringUtil.isEmpty(code)||StringUtil.isEmpty(type)){
            return Result.error("必要参数为空");

        }
        //修改状态
        if("add".equals(type)){
            SharesDetail sharesDetail = SharesConstan.CODE_DETAIL_MAP.get("sh" + code);
            if(null!=sharesDetail){
                sharesDetail.setType(SharesConstan.GZ);
                sharesDetailService.updateById(sharesDetail);
            }
        }else{

        }

        return  Result.success("更新成功");
    }
    /**
     * 获取关注的股的信息
     */
    @RequestMapping("/getSharesByType")
    public Result getSharesByType(HttpServletRequest request) {
        String type = request.getParameter("type");
        //获取关注的股

        if(SharesConstan.GZ.equals(type)){
            List<HintShares> hintSharesList=new ArrayList<>();
            for (String key : SharesConstan.GZ_HINTSHARES_MAP.keySet()) {
                HintShares hintShares = SharesConstan.GZ_HINTSHARES_MAP.get(key);
                hintSharesList.add(hintShares);
            }
            //处理显示数据
            hintSharesService.doHint(hintSharesList);
            return  Result.success(hintSharesList);
        }
        //获取最近异常股
        if(SharesConstan.HI.equals(type)){
            List<HintShares> hintSharesList=new ArrayList<>();
            for (String key : SharesConstan.HI_HINTSHARES_MAP.keySet()) {
                HintShares hintShares = SharesConstan.HI_HINTSHARES_MAP.get(key);
                hintSharesList.add(hintShares);
            }
            //处理显示数据
            hintSharesService.doHint(hintSharesList);
            return  Result.success(hintSharesList);
        }
        return  Result.success();
    }


    /**
     * 股东人数变化
     */
    @RequestMapping("/getGdchange")
    public Result getGdchange() {
        return  Result.success(SharesConstan.GDCHANGE_MAP);
    }
    /**
     * 股东人数变化
     */
    @RequestMapping("/getLately")
    public Result getLately() {
        return  Result.success(SharesConstan.HI_SHARES_MAP);
    }

    /**
     * 行业咨询
     */
    @RequestMapping("/gethyzx")
    public Result gethyzx(){
        Wrapper<SharesHyzx> wr=new EntityWrapper<>();
        List<SharesHyzx> sharesHyzxes = sharesHyzxService.selectList(wr);

        Map<String,List<SharesHyzx>> map=new HashMap<>();
        for (SharesHyzx sharesHyzx : sharesHyzxes) {
            String sshy = sharesHyzx.getName();
            List<SharesHyzx> voList = map.get(sshy);
            if(!CollectionUtils.isEmpty(voList)){
                voList.add(sharesHyzx);
            }else{
                List<SharesHyzx> toList=new ArrayList<>();
                toList.add(sharesHyzx);
                map.put(sshy,toList);
            }
        }
        return  Result.success(map);
    }

    /**
     * 个股公告
     */
    @RequestMapping("/getgggg")
    public Result getgggg(){
        Wrapper<SharesNotice> wrd=new EntityWrapper<>();
        wrd.ge("time",DateUtil.getYMDByDaysAgo(7)+" 00:00:00");
        List<SharesNotice> sharesNotices = sharesNoticeService.selectList(wrd);
        return  Result.success(sharesNotices);
    }

    /**
     * 行业资金流入
     */
    @RequestMapping("/getzjld")
    public Result getzjld(){

        List<SharesZjlx>  bkList=new ArrayList<>();
        for (String key : SharesConstan.BKZJ_MAP.keySet()) {
            SharesZjlx sharesZjlx = SharesConstan.BKZJ_MAP.get(key);
            bkList.add(sharesZjlx);
        }
        //最小值    //当前差距  //最大差距
        MeUtils.getMinVue(bkList);
        List<SharesZjlx> collect = bkList.stream().sorted(Comparator.comparing(SharesZjlx::getIndex)).collect(Collectors.toList());

        return  Result.success(collect);
    }
    /**
     * 概念资金流入
     */
    @RequestMapping("/getzjldgn")
    public Result getzjldgn(){

        List<SharesZjlx>  bkList=new ArrayList<>();
        for (String key : SharesConstan.GNZJ_MAP.keySet()) {
            SharesZjlx sharesZjlx = SharesConstan.GNZJ_MAP.get(key);
            bkList.add(sharesZjlx);
        }
        //最小值    //当前差距  //最大差距
        MeUtils.getMinVue(bkList);
        List<SharesZjlx> collect = bkList.stream().sorted(Comparator.comparing(SharesZjlx::getIndex)).collect(Collectors.toList());

        return  Result.success(collect);
    }

    /**
     * 利空利好
     */
    @RequestMapping("/getlklh")
    public Result getlklh(){
        Wrapper<SharesNotice> wrd=new EntityWrapper<>();
        wrd.ge("time",DateUtil.getYMDByDaysAgo(7)+" 00:00:00");
        List<SharesNotice> sharesNotices = sharesNoticeService.selectList(wrd);
        return  Result.success(sharesNotices);
    }

    /**
     * 个股资金流入
     */
    @RequestMapping("/getGgPrecent")
    public Result getGgPrecent(HttpServletRequest request){
        List<SshyPrecentVo>  sshyPrecentVos=new ArrayList<>();

        List<SharesZjlx>  bkList=new ArrayList<>();
        for (String key : SharesConstan.GGZJ_MAP.keySet()) {
            SharesZjlx sharesZjlx = SharesConstan.GGZJ_MAP.get(key);
            bkList.add(sharesZjlx);
        }

        String order = request.getParameter("order");

        if("max".equals(order)){//资金流入大小
            List<SharesZjlx> collect = bkList.stream().sorted(Comparator.comparing(SharesZjlx::getIndex)).collect(Collectors.toList());
            return  Result.success(collect);
        }
        if("gap".equals(order)){//资金流入差值
            List<SharesZjlx> collect = bkList.stream().sorted(Comparator.comparing(SharesZjlx::getMaxGap)).collect(Collectors.toList());
            return  Result.success(collect);
        }
        List<SshyPrecentVo> collect = sshyPrecentVos.stream().sorted(Comparator.comparing(SshyPrecentVo::getNum).reversed()).collect(Collectors.toList());
        return  Result.success(collect);

    }

    /**
     * 行业资金流入
     */
    @RequestMapping("/getSshyPrecent")
    public Result getSshyPrecent(HttpServletRequest request){
        List<SshyPrecentVo>  sshyPrecentVos=new ArrayList<>();
        for (String key :  SharesConstan.SSHY_PERCENT.keySet()) {
            Integer integer = SharesConstan.SSHY_PERCENT.get(key);
            BigDecimal divide = new BigDecimal(integer).divide(new BigDecimal(SharesConstan.INFORM_SHARES_MAP.size()), 2, BigDecimal.ROUND_HALF_UP);
            SshyPrecentVo sshyPrecentVo=new SshyPrecentVo() ;
            sshyPrecentVo.setNum(integer);
            sshyPrecentVo.setSshy(key);
            sshyPrecentVo.setPrecent(divide.toString());
            sshyPrecentVos.add(sshyPrecentVo);
        }


//        List<SharesZjlx>  bkList=new ArrayList<>();
//        for (String key : SharesConstan.BKZJ_MAP.keySet()) {
//            SharesZjlx sharesZjlx = SharesConstan.BKZJ_MAP.get(key);
//            bkList.add(sharesZjlx);
//        }
//        //最小值    //当前差距  //最大差距
//        MeUtils.getMinVue(bkList);
//        Map<String,SharesZjlx> zjMap=new HashMap<>();
//        for (SharesZjlx sharesZjlx : bkList) {
//            zjMap.put(sharesZjlx.getF14(),sharesZjlx);
//        }

        for (SshyPrecentVo sshyPrecentVo : sshyPrecentVos) {
            String sshy = sshyPrecentVo.getSshy();
            SharesZjlx vo = SharesConstan.BKZJ_MAP.get(sshy);
            if(null!=vo){
                sshyPrecentVo.setIndex(vo.getIndex());
                sshyPrecentVo.setMaxGap(vo.getMaxGap());
            }
        }

        String order = request.getParameter("order");
        if(StringUtil.isEmpty(order)){//默认排序
            List<SshyPrecentVo> collect = sshyPrecentVos.stream().sorted(Comparator.comparing(SshyPrecentVo::getNum).reversed()).collect(Collectors.toList());
            return  Result.success(collect);
        }

        if("max".equals(order)){//资金流入大小
            List<SshyPrecentVo> collect = sshyPrecentVos.stream().sorted(Comparator.comparing(SshyPrecentVo::getIndex)).collect(Collectors.toList());
            return  Result.success(collect);
        }
        if("gap".equals(order)){//资金流入差值
            List<SshyPrecentVo> collect = sshyPrecentVos.stream().sorted(Comparator.comparing(SshyPrecentVo::getMaxGap)).collect(Collectors.toList());
            return  Result.success(collect);
        }
        List<SshyPrecentVo> collect = sshyPrecentVos.stream().sorted(Comparator.comparing(SshyPrecentVo::getNum).reversed()).collect(Collectors.toList());
        return  Result.success(collect);
    }

    /**
     * 所属概念提示
     * @return
     */
    @RequestMapping("/getSsGnPrecent")
    public Result getSsGnPrecent(HttpServletRequest request){
        List<SshyPrecentVo>  sshyPrecentVos=new ArrayList<>();
        Set<String> set = SharesConstan.INFORM_SHARES_MAP.keySet();
        Map<String,Integer> gnMap=new HashMap<>();
        int size=0;
        for (String code : set) {
            HintShares hintShares = SharesConstan.INFORM_SHARES_MAP.get(code);
            String ssgn = hintShares.getSsgn();
            if(!StringUtil.isEmpty(ssgn)){
                List<String> strSsgn = JSONObject.parseArray(ssgn, String.class);
                for (String strVo : strSsgn) {
                    Integer integer = gnMap.get(strVo);
                    if(null==integer){
                        gnMap.put(strVo,1);
                        size++;
                    }else{
                        gnMap.put(strVo,integer+1);
                        size++;
                    }
                }
            }
        }

        Map<String,String> ssMap=new HashMap<>();
        for (String key : gnMap.keySet()) {
            Integer integer = gnMap.get(key);
            BigDecimal divide = new BigDecimal(integer).divide(new BigDecimal(size), 2, BigDecimal.ROUND_HALF_UP);
            SshyPrecentVo sshyPrecentVo=new SshyPrecentVo() ;
            sshyPrecentVo.setSshy(key);
            sshyPrecentVo.setNum(integer);
            sshyPrecentVo.setPrecent(divide.toString());
            sshyPrecentVos.add(sshyPrecentVo);
            ssMap.put(key,divide.toString());
        }

//        List<SharesZjlx>  bkList=new ArrayList<>();
//        for (String key : SharesConstan.GNZJ_MAP.keySet()) {
//            SharesZjlx sharesZjlx = SharesConstan.GNZJ_MAP.get(key);
//            bkList.add(sharesZjlx);
//        }
//        //最小值    //当前差距  //最大差距
//        MeUtils.getMinVue(bkList);
//        Map<String,SharesZjlx> zjMap=new HashMap<>();
//        for (SharesZjlx sharesZjlx : bkList) {
//            zjMap.put(sharesZjlx.getF14(),sharesZjlx);
//        }

        for (SshyPrecentVo sshyPrecentVo : sshyPrecentVos) {
            String sshy = sshyPrecentVo.getSshy();
            SharesZjlx vo = SharesConstan.GNZJ_MAP.get(sshy);
            if(null!=vo){
                sshyPrecentVo.setIndex(vo.getIndex());
                sshyPrecentVo.setMaxGap(vo.getMaxGap());
            }
        }

        String order = request.getParameter("order");
        if(StringUtil.isEmpty(order)){//默认排序
            List<SshyPrecentVo> collect = sshyPrecentVos.stream().sorted(Comparator.comparing(SshyPrecentVo::getNum).reversed()).collect(Collectors.toList());
            return  Result.success(collect);
        }

        if("max".equals(order)){//资金流入大小
            List<SshyPrecentVo> collect = sshyPrecentVos.stream().sorted(Comparator.comparing(SshyPrecentVo::getIndex)).collect(Collectors.toList());
            return  Result.success(collect);
        }
        if("gap".equals(order)){//资金流入差值
            List<SshyPrecentVo> collect = sshyPrecentVos.stream().sorted(Comparator.comparing(SshyPrecentVo::getMaxGap)).collect(Collectors.toList());
            return  Result.success(collect);
        }
        List<SshyPrecentVo> collect = sshyPrecentVos.stream().sorted(Comparator.comparing(SshyPrecentVo::getNum).reversed()).collect(Collectors.toList());
        return  Result.success(collect);
    }
    /**
     * 查询当天提示的代码
     */
    @RequestMapping("/getHiCode")
    public Result getHiCode(HttpServletRequest request){
        String time=request.getParameter("time");
        if(StringUtil.isEmpty(time)){
            time= DateUtil.getDate_yyyyMMdd();
        }
        Set<String> set = SharesConstan.INFORM_SHARES_MAP.keySet();
        List<HintShares> hintSharesList=new ArrayList<>();
        Map<String,Integer> numMap=new HashMap<>();
        for (String s : set) {
            HintShares hintShares = SharesConstan.INFORM_SHARES_MAP.get(s);
            hintSharesList.add(hintShares);
        }

        List<HintShares> collect = hintSharesList.stream().sorted(Comparator.comparing(HintShares::getTsOrder)).collect(Collectors.toList());

        String code = request.getParameter("code");
        if(!StringUtil.isEmpty(code)){
            Iterator<HintShares> iterator = collect.iterator();
            while (iterator.hasNext()){
                HintShares next = iterator.next();
                String voCode = next.getCode();
                if(!voCode.contains(code)){
                    iterator.remove();
                    continue;
                }
            }
        }
        //处理显示数据
        hintSharesService.doHint(collect);

        for (HintShares hintShares : collect) {
            Integer intvo = numMap.get(hintShares.getSshy());
            if(null==intvo){
                numMap.put(hintShares.getSshy(),1);
            }else{
                numMap.put(hintShares.getSshy(),intvo+1);
            }
        }
        for (HintShares hintShares : collect) {
            Integer ssIntVo = numMap.get(hintShares.getSshy());
            BigDecimal percent = new BigDecimal(ssIntVo).divide(new BigDecimal(collect.size()), 2, BigDecimal.ROUND_HALF_UP);
            BigDecimal multiply = percent.multiply(new BigDecimal("100"));
            hintShares.setSshyPercent(multiply.toString().replace(".00",""));
        }

        //所属行业占比
        SharesConstan.SSHY_PERCENT=numMap;

        //条件筛选
        String ts = request.getParameter("ts");
        String cm = request.getParameter("cm");
        String zfs = request.getParameter("zfs");
        String yfs = request.getParameter("yfs");
        String zzdf = request.getParameter("zzdf");
        String zmax = request.getParameter("zmax");
        String zf = request.getParameter("zf");
        String jj = request.getParameter("jj");
        String xtj = request.getParameter("xtj");
        String gn = request.getParameter("gn");
        String bg = request.getParameter("bg");
        String hy = request.getParameter("hy");
        String yczfs = request.getParameter("yczfs");
        String ycyfs = request.getParameter("ycyfs");
        String db = request.getParameter("db");
        String yd = request.getParameter("yd");
        String jz = request.getParameter("jz");
        String zyz = request.getParameter("zyz");
        String tsnum = request.getParameter("tsnum");
        String mavg = request.getParameter("mavg");
        Iterator<HintShares> iterator = collect.iterator();
        while (iterator.hasNext()){
            HintShares hintShares = iterator.next();
            //电波
            if(!StringUtil.isEmpty(db)){
                String magical = hintShares.getMagical();
                if(StringUtil.isEmpty(magical)){
                    iterator.remove();
                    continue;
                }
                if(!StringUtil.isEmpty(magical)&&Integer.valueOf(magical)>9){
                    iterator.remove();
                    continue;
                }
            }
            //条件一ts
            if(!StringUtil.isEmpty(ts)){
                Integer keepNum = hintShares.getKeepNum();
                if(keepNum<66){
                    iterator.remove();
                    continue;
                }
            }
            //条件二cm
            if(!StringUtil.isEmpty(cm)){
                List<SharesGdChange> sharesGdChanges = hintShares.getSharesGdChanges();
                if(!CollectionUtils.isEmpty(sharesGdChanges)){
                    String holdFocus = sharesGdChanges.get(0).getHoldFocus();
                    if(!holdFocus.contains("集中")){
                        iterator.remove();
                        continue;
                    }
                }
            }
            //条件三zfs
            if(!StringUtil.isEmpty(zfs)){
                List<SharesZdfCopyVo> zvoList = hintShares.getZvoList();
                if(!CollectionUtils.isEmpty(zvoList)){
                    if(zvoList.size()-hintShares.getZzfsign()>3){
                        iterator.remove();
                        continue;
                    }
                }
            }
            //条件四yfs
            if(!StringUtil.isEmpty(yfs)){
                List<SharesZdfCopyVo> yvoList = hintShares.getYvoList();
                if(!CollectionUtils.isEmpty(yvoList)){
                    if(yvoList.size()-hintShares.getYzfsign()>3){
                        iterator.remove();
                        continue;
                    }
                }
            }
            //预测周涨停后yczfs
            if(!StringUtil.isEmpty(yczfs)){
                List<SharesZdfCopyVo> zvoList = hintShares.getZvoList();
                if(!CollectionUtils.isEmpty(zvoList)){
                    if(zvoList.size()-hintShares.getMaxzsgin()>2){
                        iterator.remove();
                        continue;
                    }
                }
            }
            //预测涨停后月分数
            if(!StringUtil.isEmpty(ycyfs)){
                List<SharesZdfCopyVo> yvoList = hintShares.getYvoList();
                if(!CollectionUtils.isEmpty(yvoList)){
                    if(yvoList.size()-hintShares.getMaxysgin()>2){
                        iterator.remove();
                        continue;
                    }
                }
            }
            //条件五zzf
            if(!StringUtil.isEmpty(zzdf)){
                String newZdf = hintShares.getNewZdf();
                String zzdfsub = hintShares.getZzdfsub();
                if(!StringUtil.isEmpty(zzdfsub)&&!StringUtil.isEmpty(newZdf)){
                    BigDecimal subtract = new BigDecimal("20").subtract(new BigDecimal(newZdf));//还能够继续涨多少个点
                    BigDecimal zzdadd = subtract.add(new BigDecimal(zzdfsub));//涨停后再什么范围内
                    if(zzdadd.intValue()<0||zzdadd.intValue()>20){
                                iterator.remove();
                                 continue;
                    }
                }

            }
            //条件六zmax
            if(!StringUtil.isEmpty(zmax)){
                String newZdf = hintShares.getNewZdf();
                String maxzzdf = hintShares.getMaxzzdf();
                if(!StringUtil.isEmpty(newZdf)&&!StringUtil.isEmpty(maxzzdf)){
                    BigDecimal subtract = new BigDecimal("20").subtract(new BigDecimal(newZdf));//还能够继续涨多少个点
                    BigDecimal add = subtract.add(new BigDecimal(maxzzdf));//涨停后再什么范围内
                    if(add.intValue()<0||add.intValue()>20){
                        iterator.remove();
                        continue;
                    }
                }
            }

            //涨幅
            if(!StringUtil.isEmpty(zf)){
                String newZdf = hintShares.getNewZdf();
                if(!StringUtil.isEmpty(newZdf)){
                    if(new BigDecimal(newZdf).compareTo(new BigDecimal("10"))!=1){
                        iterator.remove();
                        continue;
                    }
                }else{
                    iterator.remove();
                    continue;
                }
            }

            //解禁
            if(!StringUtil.isEmpty(jj)){
                Long unfastenDay = hintShares.getUnfastenDay();
                if(unfastenDay>30){
                    iterator.remove();
                    continue;
                }
            }

            //新统计
            if(!StringUtil.isEmpty(xtj)){
                List<SharesGdnum> sharesGdnums = hintShares.getSharesGdnums();
                if(!CollectionUtils.isEmpty(sharesGdnums)){
                    String endDate = sharesGdnums.get(0).getEndDate();
                    if(endDate.contains("09-30")){
                        iterator.remove();
                        continue;
                    }
                }
            }
            //概念
            if(!StringUtil.isEmpty(gn)){
                String ssgn = hintShares.getSsgn();
                if(!StringUtil.isEmpty(ssgn)){
                    if(!ssgn.contains(gn)){
                        iterator.remove();
                        continue;
                    }
                }
            }
            //报告
            if(!StringUtil.isEmpty(bg)){
                List<SharesYjbg> sharesYjbgs = hintShares.getSharesYjbgs();
                if(!CollectionUtils.isEmpty(sharesYjbgs)){
                    String ystz = sharesYjbgs.get(0).getYstz();
                    String sjltz = sharesYjbgs.get(0).getSjltz();
                    if(!StringUtil.isEmpty(ystz)&&!StringUtil.isEmpty(sjltz)){
                        if(new BigDecimal(ystz).compareTo(new BigDecimal(0))==-1||
                        new BigDecimal(sjltz).compareTo(new BigDecimal(0))==-1){
                            iterator.remove();
                            continue;
                        }
                    }
                }
            }

            //所属行业
            if(!StringUtil.isEmpty(hy)){
                String sshy = hintShares.getSshy();
                if(!StringUtil.isEmpty(sshy)){
                    if(!sshy.equals(hy)){
                        iterator.remove();
                        continue;
                    }
                }
            }

            //极限周涨幅，极限月涨幅
            //异动
            if(!StringUtil.isEmpty(yd)){
                int ydInt = hintShares.getYd();
                if(SharesConstan.YD_INT !=ydInt){
                    iterator.remove();
                    continue;
                }
            }

            //jz 九转
            if(!StringUtil.isEmpty(jz)){
                int index = hintShares.getIndex();
                if(index<4){
                    iterator.remove();
                    continue;
                }
            }

            //zyzf null
            if(StringUtil.isEmpty(zyz)){
                String bzzf = hintShares.getBzzf();//本周涨幅
                String byzf = hintShares.getByzf();//本月涨幅
                if(!StringUtil.isEmpty(byzf)&&!StringUtil.isEmpty(bzzf)){
                    if(new BigDecimal(bzzf).compareTo(new BigDecimal("0"))==-1
                            ||new BigDecimal(byzf).compareTo(new BigDecimal("0"))==-1){
                        iterator.remove();
                        continue;
                    }
                }
            }

            //提示次数小于3次
            if(!StringUtil.isEmpty(tsnum)){
                Integer tsNum = hintShares.getTsNum();
                if(null==tsNum||tsNum<3){
                    iterator.remove();
                    continue;
                }
            }

            //分时均线
            if(!StringUtil.isEmpty(mavg)){
                Integer mavgSign = hintShares.getMavgSign();
                if(null!=mavgSign&&1==mavgSign){
                    iterator.remove();
                    continue;
                }
            }

            if(StringUtil.isEmpty(code)){
                hintShares.getCode();
            }
        }
        return  Result.success(collect);
    }

    /**
     * 复盘
     */
    @RequestMapping("/review")
    public Result getReview(HttpServletRequest request){
        String time = request.getParameter("time");
        if(StringUtil.isEmpty(time)){
            time=DateUtil.getDate_yyyyMMdd();
        }

        Wrapper<SharesReview> wr=new EntityWrapper<>();
        wr.eq("time",time);
        List<SharesReview> reviewList = sharesReviewService.selectList(wr);

        if(CollectionUtils.isEmpty(reviewList)){
           return Result.success();
        }
        List<HintShares> collect = sharesReviewService.changeHi(reviewList);
        return  Result.success(collect);
    }

    /**
     * 获取提示数据
     */
    @RequestMapping("/hintNum")
    public Result hintNum(){
      return  hintNumService.hintNum();
    }

    /**
     * 大涨股相关股票
     */
    @RequestMapping("/highzdf")
    public  Result highzdf(HttpServletRequest request){
        return  hintSharesService.highzdf(request);
    }

}
